//
//  ViewController.swift
//  LeetCodeDemo
//
//  Created by Clover on 2018/7/2.
//  Copyright © 2018年 longbei.com. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
     
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
//        let arrDemo = YBArray.init()
//        var arr = [0,0,1,1,1,2,2,3,3,4]
//        let value = arrDemo.removeDuplicates(&arr)
//        print(value)
//        print(arr)
//
////        2.
//        var Arr_2 = [1,2,3,4,5,6,7]
//        let K_2 = 1
//        arrDemo.rotate(&Arr_2, K_2)
//        print(Arr_2)
//
////        3
//        let arr_3 = [1,2,3,4,5]
//        let max_3 = arrDemo.maxProfit(arr_3)
//        print(max_3)
////        4
//        let arr_4 = [1,1,1,3,3,4,3,2,4,2]
//        print(arrDemo.containsDuplicate(arr_4))
        
//        5
//        let arr_5 = [1,3,1,-1,3]
//        print(arrDemo.singleNumber(arr_5))
        
//        6
//        let arr_6_2:[Int] = [1,2]
//        let arr_6 = [2,1]
//        print(arrDemo.intersect(arr_6, arr_6_2))
        
//        7
//        let arr_7 = [9,9,9,9]
//        print(arrDemo.plusOne(arr_7))
        
//        8
//        var arr_8 =  [-959151711,623836953,209446690,-1950418142,1339915067,-733626417,481171539,-2125997010,-1225423476,1462109565,147434687,-1800073781,-1431212205,-450443973,50097298,753533734,-747189404,-2070885638,0,-1484353894,-340296594,-2133744570,619639811,-1626162038,669689561,0,112220218,502447212,-787793179,0,-726846372,-1611013491,204107194,1605165582,-566891128,2082852116,0,532995238,-1502590712,0,2136989777,-2031153343,371398938,-1907397429,342796391,609166045,-2007448660,-1096076344,-323570318,0,-2082980371,2129956379,-243553361,-1549960929,1502383415,0,-1394618779,694799815,78595689,-1439173023,-1416578800,685225786,-333502212,-1181308536,-380569313,772035354,0,-915266376,663709718,1443496021,-777017729,-883300731,-387828385,1907473488,-725483724,-972961871,-1255712537,383120918,1383877998,1722751914,0,-1156050682,1952527902,-560244497,1304305692,1173974542,-1313227247,-201476579,-298899493,-1828496581,-1724396350,1933643204,1531804925,1728655262,-955565449,0,-69843702,-461760848,268336768,1446130876]
//        arrDemo.moveZeroes(&arr_8)
//        print(arr_8)
        
//        9
//        var arr_9 = [2, 7, 11, 15]
//        print(arrDemo.twoSum(arr_9, 9))
        
//        10
//        var arr_10 =  [
//            ["8","3",".",".","7",".",".",".","."],
//            ["6",".",".","1","9","5",".",".","."],
//            [".","9","8",".",".",".",".","6","."],
//            ["8",".",".",".","6",".",".",".","3"],
//            ["4",".",".","8",".","3",".",".","1"],
//            ["7",".",".",".","2",".",".",".","6"],
//            [".","6",".",".",".",".","2","8","."],
//            [".",".",".","4","1","9",".",".","5"],
//            [".",".",".",".","8",".",".","7","9"]
//        ]
//        print(arrDemo.isValidSudoku(arr_10))
        
//MARK: - String
//        let ybStr = YBString.init()
        
//        let value = 1534236469
//        print(ybStr.reverse(value))
        
//        let str_2 = "aadadaad"
//        print(ybStr.firstUniqChar(str_2))
        
//        let str_3_1 = "anagram"
//        let str_3_2 = "nagaram"
//        print(ybStr.isAnagram(str_3_1, str_3_2))
        
        let testDemo = StringDemo()
        var arr = [4,1,2,1,2]
//        testDemo.rotate(&arr,3)
//        print(testDemo.containsDuplicate(arr))
//        print(testDemo.singleNumber(arr))
        var nodeHead = ListObjc.ListNode.init(1)
        var nodeHead2 = ListObjc.ListNode.init(9)
        var nextNode = nodeHead
        var nextNode2 = nodeHead2
        
        for i  in 2...6 {
            let node = ListObjc.ListNode.init(i)
            nextNode.next = node;
            nextNode = node
        }
        
        for i  in 0...3 {
            let node = ListObjc.ListNode.init(9)
            nextNode2.next = node;
            nextNode2 = node
        }
        
//        let value = Solution().reversePrint(nodeHead)
//        let value = Solution().reverseLeftWords("abcdefg", 2)
//        let value = Solution().maxSlidingWindow([1,-1], 1)
//        let value = Solution().fib(95)
//        let value = Solution().reverse(123)
//        let value = Solution().firstUniqChar("loveleetcode")
//        let value = Solution().isAnagram("a", "b")
//        let value = Solution().isPalindrome("a.")
//        let value = Solution().strStr("hello", "ll")
//        let value = StringDemo().maxProfit(prices: [7,1,5,3,6,4])
//        let value = Solution().maxProfit([7,1,5,3,6,4])
//        let value = Solution().validMountainArray([1,2,3,4,3,2,1])
//        let value = Solution().removeNthFromEnd(nodeHead, 1)
//        let value = Solution().reverseList(nodeHead)
//        let value = Solution() .mergeTwoLists(nodeHead, nodeHead2)
//        let value = Solution().isPalindrome(nodeHead)
//        let value = TreeMapObj().maxDepth)
//        let value = Solution().breakfastNumber([2,1,1], [8,9,5,1], 9)
//        let value = Solution().rob([2,1,1,2])
//        let value = Solution().twoSum([2,7,1,15], 9)
//        let value = Solution().insert([[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8])
//        let value = StringDemo().isValid(")(){}")
//        let value = Solution().findMedianSortedArrays([], [1])
//        let value = Solution().sortByBits([0,1,2,3,4,5,6,7,8])
//        let value = ListObjc().addTwoNumbers(nodeHead, nodeHead2)
//        let value = StringDemo().lengthOfLongestSubstring("dvdf")
//        let value = StringDemo().longestPalindrome("civilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth")
//        let value = Solution().sortArrayByParityII([4,2,5,7])
//        let value = ListObjc().oddEvenList(nodeHead)
        var listArr = [0,1,0,3,12]
        Solution().moveZeroes(&listArr)
        print(listArr)
    }

}

